package com.fmsz.xmly.fragments;


import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.fmsz.xmly.R;
import com.fmsz.xmly.adapters.DownloadAdapter;
import com.fmsz.xmly.utils.PhoneInfo;

import java.util.ArrayList;
import java.util.List;

/**
 * A simple {@link Fragment} subclass.
 */
public class DownloadFragment extends Fragment {

    private TabLayout tabLayout_down;
    private ViewPager viewPager_down;
    private TextView ram;
    private List<String> titles;
    private DownloadAdapter adapter;

    public DownloadFragment() {
        // Required empty public constructor
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.fragment_download, container, false);

    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        tabLayout_down = (TabLayout) view.findViewById(R.id.tabLayout_down);
        viewPager_down = (ViewPager) view.findViewById(R.id.viewPage_down);
        //内存大小
        ram = (TextView) view.findViewById(R.id.ram_size);

        titles = new ArrayList<>();
        titles.add("专辑");
        titles.add("声音");
        titles.add("下载中");

        adapter = new DownloadAdapter(getFragmentManager(), titles);
        viewPager_down.setAdapter(adapter);
        tabLayout_down.setupWithViewPager(viewPager_down);

        ram.setText("可用" + PhoneInfo.getSDAvailableSize(getContext()) + "G,共" + PhoneInfo.getSDTotalSize(getContext()) + "G");
    }


}
